package com.gite.nouette.admin.implementation.controller;

import com.gite.nouette.admin.contract.controller.IController;
import com.gite.nouette.admin.contract.model.IModel;
import com.gite.nouette.admin.contract.view.IView;

public abstract class AbstractController<V extends IView<?>, M extends IModel>
		implements IController<V, M> {

	private V v;
	private M m;

	public AbstractController() {
	}

	public AbstractController(V v, M m) {
		setV(v);
		setM(m);
	}

	@Override
	public V getV() {
		return v;
	}

	@Override
	public void setV(V v) {
		this.v = v;
	}

	@Override
	public M getM() {
		return m;
	}

	@Override
	public void setM(M m) {
		this.m = m;
	}

	@Override
	public int getId() {
		return getM().getId();
	}

	@Override
	public void setId(int id) {
		getM().setId(id);
	}

	@Override
	public String getName() {
		return getM().getName();
	}

	@Override
	public void setName(String name) {
		getM().setName(name);
		getV().setName(name);
	}

	@Override
	public void init() {
		getV().setName(getM().getName());
	}

	@Override
	public int compareTo(IModel model) {
		return getM().compareTo(model);
	}
}
